FROM debian:latest

ADD ./nginx-rtmp-module-master.zip /usr/local/src/
ADD ./nginx-1.21.6.zip /usr/local/src/

RUN sed -i "s@http://deb.debian.org@http://mirrors.ustc.edu.cn@g" /etc/apt/sources.list 
RUN apt update -y && apt install -y zip unzip gcc g++ cmake 

WORKDIR /usr/local/src/

RUN apt install -y libpcre3 libpcre3-dev openssl libssl-dev zlib1g zlib1g-dev \
    && unzip nginx-1.21.6.zip \
    && unzip nginx-rtmp-module-master.zip \
	&& cd nginx-1.21.6 \
	&& chmod +x ./configure \
    && ./configure --with-http_ssl_module --add-module=../nginx-rtmp-module-master \
	&& make \
	&& make install \
    && mv ../nginx-rtmp-module-master /usr/local/nginx/nginx-rtmp-module \
	&& cd /usr/local/nginx/ \
	&& \cp ./nginx-rtmp-module/test/nginx.conf ./conf/nginx.conf \
	&& sed -i "s@/path/to/nginx-rtmp-module/@nginx-rtmp-module@g" ./conf/nginx.conf 

	
WORKDIR /
	
VOLUME /usr/local/nginx/conf

EXPOSE 1935 8080

CMD ["/usr/local/nginx/sbin/nginx", "-g", "daemon off;"]